package com.lsec.springbootinit.controller;

import com.lsec.springbootinit.exception.enums.TypicalCode;
import com.lsec.springbootinit.model.common.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;


/**
 *
 *
 * @author Cherry
 * @date 2023/03/03
 */
@Slf4j
@RestController
public class FormatController {



    @GetMapping("test3")
    public Integer userList3(){
        return 11;
    }

    @GetMapping("test4")
    public String userList4(){
        return "11";
    }

    @GetMapping("test5")
    public Long userList5(){
        return 1L;
    }

    @GetMapping("test6")
    public List<String> userList6(){
        return Arrays.asList("11");
    }

    @GetMapping("test7")
    public int userList7(){
        return 1 / 0;
    }

    @GetMapping("test8")
    public int userList8(){
        throw new ServiceException(TypicalCode.ACCESS_DENIED);
    }


    /**
     * GET 方式接口测试
     * @return
     */
    @GetMapping("/user")
    public String testGet(@RequestParam("username") String username,
                          @RequestParam("password") String password) {
        log.info("testGet ...");
        return "success";
    }
    /**
     * 单文件上传接口测试
     * @return
     */
    @PostMapping("/file/upload")
    public String testFileUpload(@RequestParam("file") MultipartFile file) {
        log.info("testFileUpload ...");
        return "success";
    }

}
